package com.example.infra.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.infra.po.MenuPo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface MenuMapper extends BaseMapper<MenuPo> {

    @Select("SELECT m.* FROM menus m \n" +
            "JOIN roles_menus rm ON m.id = rm.menu_id \n" +
            "JOIN users_roles ur ON rm.role_id = ur.role_id \n" +
            "WHERE ur.user_id = #{userId}")
    List<MenuPo> selectByUserId(Integer userId);
}


